# -*- coding: utf-8 -*-
class PriceController < ApplicationController
  before_filter :user_authorize
  before_filter :sys_before_log
  
  def getAllPrices
    
    prices = Price.all
    jsonStr="{totalProperty:"+prices.length.to_s+",root:"+prices.to_json()+"}"

    puts jsonStr
    render :text=>jsonStr, :layout=>false
  end

  def editPrice
    
    @priceId = params[:price_id]
  end

  def getPriceById
    
    price = Price.find(params[:price_id])
    rootStr = price.to_json()
    jsonStr = "{root:["+rootStr+"]}"
    puts jsonStr
    render :text=>jsonStr, :layout=>false
  end

  def updatePrice
    price = Price.find(params[:id])
    price.price = params[:price]
    price.save
    info = "成功"
    result = "{success:true,info:'#{info}'}"
    render :text=>result, :layout=>false
  end
end
